<?php

class Lw_js {

    protected $CI;
    public function __construct()
    {
        $this->CI =& get_instance();
    }

    function alert($mes){
        echo "<script> alert('{$mes}');</script>";
    }

    function jump($url){
        echo "<script>window.location='{$url}';</script>";
    }

    function back(){
        echo "<script>history.go(-1);</script>";
    }

    //PHP调用js 退出当前页
    function close(){
        echo "<script>window.close();</script>";
    }

    function checkLogined(){
        if($this->CI->session->userId == null || $this->CI->session->userId == ""){
            $this->jump("loginout/index");
            exit;
        }
    }

    function goHome(){
        $this->jump(site_url('home/index'));
    }
}